package com.alkaid.novel.controller;

import com.alkaid.commons.controller.BaseController;
import com.alkaid.commons.entity.Novel;
import com.alkaid.commons.utils.JsonResult;
import com.alkaid.novel.service.NovelDetailsService;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author Kylin
 */
@RestController
@RequestMapping("api/novel")
public class NovelDetailsController extends BaseController {

    private final NovelDetailsService novelDetailsService;

    public NovelDetailsController(NovelDetailsService novelDetailsService) {
        this.novelDetailsService = novelDetailsService;
    }

    @GetMapping("/play/eq/{id}")
    public JsonResult<Novel> getNovelPlayByVideoId(@PathVariable Integer id) {
        Novel novel = novelDetailsService.getNovelWithDetailsByDetailId(id);
        return new JsonResult<>(200, novel, "success");
    }

    /**
     * 小说详情
     *
     * @param id the id
     * @return the hot list
     */
    @GetMapping("/play/source/{id}")
    public JsonResult<String> getSource(@PathVariable Long id) {
        String txt = novelDetailsService.getSource(id);
        return new JsonResult<>(200, txt, "success");
    }
}
